package com.booksystem.campuslibrarymanagementsystem.commen.request.userquest.BookBorrowrequst;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;

@Data
@ApiModel("图书借阅表")
@TableName("borrowapprovals_table")
public class Approval {

    @ApiModelProperty("借阅id")
    private int recordid;

    @ApiModelProperty("审批id")
    private String accountid;

    @ApiModelProperty("图书id")
    private int bookid;

    @ApiModelProperty("借阅日期")
    private String borrowdate;

    @ApiModelProperty("借阅过期日期")
    private LocalDate expirationdate;

    @ApiModelProperty("审批状态（通过，未通过）")
    private String approvalstate;

    @ApiModelProperty("审批时间")
    private String approvaldate;

    @ApiModelProperty("借阅用户id")
    private String account;
    @ApiModelProperty("借出数量")
    private int availablecopies;

    @ApiModelProperty("总数")
    private int totalcopies;

    // 判断图书是否可以借阅
    public boolean canBeBorrowed() {
        return availablecopies < totalcopies;
    }

    @ApiModelProperty("token值")
    private String token;
}
